#include <QtGui/QApplication>
#include <QtCore/QTextCodec>
#include "globalhotkey.h"
#include "stockanalyzer.h"

int main(int argc, char *argv[])
{
    GlobalHotkey hk(argc, argv);

    QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
    QTextCodec::setCodecForCStrings(QTextCodec::codecForName("GBK"));

    StockAnalyzer w;
    w.show();

    if(hk.registerHotKey(&w) > 0)
    {
        qApp->quit();
    }

    QObject::connect(&hk, SIGNAL(signalPressedHotkey(int)), &w,
                     SLOT(slotPressedHotkey(int)));
    QObject::connect(&w, SIGNAL(signalCloseWindow()), &hk,
                     SLOT(slotUnregisterHotKey()));

    return hk.exec();
}
